import Ember from 'ember';
import BaseBusiness from '../base-business';
import Pagination from '../pagination';

export default BaseBusiness.extend(Pagination, {
  header_title: '绩效设置',
  model:function() {
      return {};
  },
  buildQueryParams:function(){
    var curController = this.getCurrentController();
    var params = {};
    let filter = {};
    if (curController.get("inTabFlag")) {
      filter = $.extend({}, filter, {'[type][typecode]': 'employeeProformanceType2'});
    } else {
      filter = $.extend({}, filter, {'[type][typecode]': 'employeeProformanceType1'});
    }
    params.filter = filter;
    return params;
  },
  doQuery:function(){
    var params = this.buildQueryParams();
    const _self = this;
    _self.getCurrentController().set("leftLoading", true);
    _self.getCurrentController().set("assessmentList", []);
    this.store.query('employeeachievementstype', params).then(function(indicatorList){
      console.log('indicatorList11:', indicatorList);
      indicatorList.forEach(function(item){
        item.set('hasChoosed',false);
      });
      _self.getCurrentController().set("assessmentList", indicatorList);
      _self.getCurrentController().set("leftLoading", false);
    });
  },
  setupController: function(controller, model) {
    this._super(controller, model);
    controller.set("inTabFlag", false);
    controller.set("rightLoading", false);
    controller.set("childrenList", []);
    this.doQuery();
  }
});
